Skip to content

ObservableAsPropertyHelper class

Attributes: [DebuggerDisplay("Value = {_lastValue}, IsSubscribed = {IsSubscribed}")]

Defined in

Namespace: ReactiveUI.Reactive Assembly: ReactiveUI.Reactive.dll Full name: ReactiveUI.Reactive.ObservableAsPropertyHelper<T> Modifiers: public sealed

Summary

View source

ObservableAsPropertyHelper is a class to help ViewModels implement "output properties", that is, a property that is backed by an Observable. The property will be read-only, but will still fire change notifications. This class can be created directly, but is more often created via the OAPHCreationHelperMixins extension methods.

Applies to

net10.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net10.0-tvos26.0, net10.0-windows10.0.19041, net10.0-macos26.0, net10.0-ios26.0, net10.0-android36.0, net9.0, net9.0-tvos18.0, net9.0-macos15.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-ios18.0, net9.0-desktop1.0, net8.0, net8.0-windows10.0.19041, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.5, netstandard2.1, net481, net462, net471

Class hierarchy
classDiagram
class ObservableAsPropertyHelper~T~
class IHandleObservableErrors {
    <>
}
IHandleObservableErrors <|.. ObservableAsPropertyHelper~T~
class IDisposable {
    <>
}
IDisposable <|.. ObservableAsPropertyHelper~T~
class IEnableLogger {
    <>
}
IEnableLogger <|.. ObservableAsPropertyHelper~T~

Implements: IHandleObservableErrors, IDisposable, IEnableLogger

Remarks

Use this helper when the value for a property is derived from one or more observable streams (for example, WhenAnyValue). The helper subscribes to the source observable, tracks the latest value, and raises change notifications through the supplied callbacks.

Examples

<![CDATA[
 _fullName = this.WhenAnyValue(x => x.FirstName, x => x.LastName,
 (first, last) => $"{first} {last}")
 .ToProperty(this, x => x.FullName);
 
 public string FullName => _fullName.Value;
 ]]>

Constructors

NameSummary
.ctorInitializes a new instance of the [ObservableAsPropertyHelper](# class with no initial value, no deferred subscription, and no scheduler.

Properties

NameSummary
ValueGets the last provided value from the Observable.
IsSubscribedGets a value indicating whether the ObservableAsPropertyHelper has subscribed to the source Observable. Useful for scenarios where you use deferred subscription and want to...
ThrownExceptionsGets an observable which signals whenever an exception would normally terminate ReactiveUI internal state.

Methods

NameSummary
static DefaultConstructs a default ObservableAsPropertyHelper with no initial value and no scheduler.
DisposeDisposes this ObservableAsPropertyHelper.
Inherited members